package ljl.alg.jianzhioffer.round3.easy;

import commons.TreeNode;

public class _28_isSymmetric {

    /*
    * 只左右交换判断不了的，必须 左左 左右 右左 右右，才能递归下去
    * todo 不知道为什么要这样搞，我是想不到的
    * */
    public boolean isSymmetric(TreeNode root) {
        if (root == null)
            return true;
        return yes(root.left, root.right);
    }
    boolean yes(TreeNode left, TreeNode right) {
        if (left == null || right == null)
            return left == right;
        if (left.val != right.val)
            return false;
        return yes(left.left, right.right) && yes(left.right, right.left);
    }
}
